package com.alks.function.controller.chengKong;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.entity.YfOrderPartName;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.chengKong.*;
import com.alks.function.service.chengKong.PartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@ApiRestController("/date")
@Api(tags = {"成控部-物料管理作业-部位资料建档"
        , "成控部-物料管理作业-面材资料建档"
        , "成控部-物料管理作业-贴合材料建档"
        , "成控部-物料管理作业-研发用量建档"
        ,"成控部-物料管理作业-大货用量建档"
        , "业务部-物料管理作业-开发用量建档"})
@Slf4j
public class PartController {

    @Autowired
    private PartService partService;

    @WebLogger
    @PostMapping("/getPartList")
    @ApiOperation(value = "部位明细",tags = "成控部-物料管理作业-部位资料建档")
    public ResponseInfo getPartList(@RequestBody PartRequest request){
        return partService.getPartList(request);
    }

    @WebLogger
    @PostMapping("/getPartAdd")
    @ApiOperation(value = "部位建档",tags = "成控部-物料管理作业-部位资料建档")
    public ResponseInfo getPartAdd(@RequestBody YfOrderPartName yfOrderPartName){
        return partService.getPartAdd(yfOrderPartName);
    }

    @WebLogger
    @PutMapping("/getPartUpdate")
    @ApiOperation(value = "部位修改",tags = "成控部-物料管理作业-部位资料建档")
    public ResponseInfo getPartUpdate(@RequestBody YfOrderPartName yfOrderPartName){
        return  partService.getPartUpdate(yfOrderPartName);
    }

    @WebLogger
    @PostMapping("/getPartDel")
    @ApiOperation(value = "部位删除",tags = "成控部-物料管理作业-部位资料建档")
    public ResponseInfo getPartDel(@RequestParam String partName){
        return partService.getPartDel(partName);
    }

    @WebLogger
    @PostMapping("/getClassification")
    @ApiOperation(value = "分类资料列表",tags = "成控部-物料管理作业-面材资料建档")
    public ResponseInfo getClassification(@RequestBody MatterRequest request){
        return partService.getClassification(request);
    }

    @WebLogger
    @PostMapping("/getMaterialProperties")
    @ApiOperation(value = "材料属性",tags = "成控部-物料管理作业-面材资料建档")
    public ResponseInfo getMaterialProperties(@RequestBody MatterRequest request){
        return partService.getMaterialProperties(request);
    }

    @WebLogger
    @PostMapping("/getMaterialPropertiesIn")
    @ApiOperation(value = "组合材料",tags = "成控部-物料管理作业-面材资料建档")
    public ResponseInfo getMaterialPropertiesIn(@RequestBody List<MaterialRequest> request){
        return partService.getMaterialPropertiesIn(request);
    }

    @WebLogger
    @PostMapping("/getMaterialPropertiesAdd")
    @ApiOperation(value = "材料属性添加",tags = "成控部-物料管理作业-面材资料建档")
    public ResponseInfo getMaterialPropertiesAdd(@RequestBody MaterialAddRequest request){
        return partService.getMaterialPropertiesAdd(request);
    }

    @WebLogger
    @PostMapping("/getMaterialQueryList")
    @ApiOperation(value = "材料查询",tags = "成控部-物料管理作业-面材资料建档")
    public ResponseInfo getMaterialQueryList(@RequestBody MaterialQueryRequest request){
        return partService.getMaterialQueryList(request);
    }

    @WebLogger
    @PostMapping("/check/{choose}")
    @ApiOperation(value = "0 未审核 1审核 2 退回",tags = "成控部-物料管理作业-面材资料建档")
    public ResponseInfo check(@RequestBody List<MaterialQueryRequest> request,@PathVariable("choose") Integer choose){
        return partService.check(request,choose);
    }

    @WebLogger
    @GetMapping("/getMaterialPropertiesDel")
    @ApiOperation(value = "材料查询删除",tags = "成控部-物料管理作业-面材资料建档")
    public ResponseInfo getMaterialPropertiesDel(@RequestParam String mtlNo){
        return partService.getMaterialPropertiesDel(mtlNo);
    }

    @WebLogger
    @PutMapping("/getMaterialPropertiesUpdate")
    @ApiOperation(value = "材料查询修改",tags = "成控部-物料管理作业-面材资料建档")
    public ResponseInfo getMaterialPropertiesUpdate(@RequestBody MaterialUpdateRequest request){
        return partService.getMaterialPropertiesUpdate(request);
    }

    @WebLogger
    @PutMapping("/getMaterialProperties2Update")
    @ApiOperation(value = "材料查询修改2",tags = "成控部-物料管理作业-面材资料建档")
    public ResponseInfo getMaterialPropertiesUpdate(@RequestBody Map<String,MaterialUpdate2Request> request){
        return partService.getMaterialProperties2Update(request);
    }

    @WebLogger
    @PostMapping("/getAdhesiveMaterial")
    @ApiOperation(value = "查询条件",tags = "成控部-物料管理作业-贴合材料建档")
    public ResponseInfo getAdhesiveMaterial(@RequestBody AdhesiveMaterialRequest request){
        return partService.getAdhesiveMaterial(request);
    }

    @WebLogger
    @PostMapping("/getCacheAdd")
    @ApiOperation(value = "贴合材料建档添加",tags = "成控部-物料管理作业-贴合材料建档")
    public ResponseInfo getCacheAdd(@RequestBody CacheAddRequest request){
        return partService.getCacheAdd(request);
    }

    @WebLogger
    @PostMapping("/getCompositeMaterials")
    @ApiOperation(value = "组成贴合材料",tags = "成控部-物料管理作业-贴合材料建档")
    public ResponseInfo getCompositeMaterials(@RequestBody List<CacheRequest> request){
        return partService.getCompositeMaterials(request);
    }

    @WebLogger
    @PostMapping("/getCompositeMaterialsAdd")
    @ApiOperation(value = "插入贴合材料",tags = "成控部-物料管理作业-贴合材料建档")
    public ResponseInfo getCompositeMaterialsAdd(@RequestBody AdhesiveMaterialAddRequest request){
        return  partService.getCompositeMaterialsAdd(request);
    }

    @WebLogger
    @PostMapping("/getCompositeMaterialsAdd2")
    @ApiOperation(value = "插入贴合材料",tags = "成控部-物料管理作业-贴合材料建档")
    public ResponseInfo getCompositeMaterialsAdd2(@RequestBody AdhesiveMaterialAddRequest request){
        return  partService.getCompositeMaterialsAdd2(request);
    }

    @WebLogger
    @GetMapping("/getCacheList")
    @ApiOperation(value = "贴合材料建档列表",tags = "成控部-物料管理作业-贴合材料建档")
    public ResponseInfo getCacheList(){
        return partService.getCacheList();
    }

    @WebLogger
    @PostMapping("/getCacheDel")
    @ApiOperation(value = "贴合材料建档删除",tags = "成控部-物料管理作业-贴合材料建档")
    public ResponseInfo getCacheDel(@RequestBody List<String> ids){
        return partService.getCacheDel(ids);
    }

    @WebLogger
    @GetMapping("/getCacheMove/{choose}")
    @ApiOperation(value = "贴合材料建档移动 0上1下",tags = "成控部-物料管理作业-贴合材料建档")
    public ResponseInfo getCacheMove(@RequestParam Integer id, @PathVariable("choose") Integer choose){
        return partService.getCacheMove(id,choose);
    }

    @WebLogger
    @PutMapping("/getCacheUpdate")
    @ApiOperation(value = "贴合材料建档修改",tags = "成控部-物料管理作业-贴合材料建档")
    public ResponseInfo getCacheUpdate(@RequestBody List<CacheRequest> request){
        return partService.getCacheUpdate(request);
    }

    @WebLogger
    @PostMapping("/getChooseCurrentMaterials")
    @ApiOperation(value = "选择材料-选择当前行正式材料到用量表",tags = "成控部-物料管理作业-研发用量建档")
    public ResponseInfo getChooseCurrentMaterials(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.getChooseCurrentMaterials(request);
    }

    @WebLogger
    @PostMapping("/getChooseCurrentMaterials2")
    @ApiOperation(value = "选择材料-选择当前行正式材料到用量表",tags = "成控部-物料管理作业-开发用量建档")
    public ResponseInfo getChooseCurrentMaterials2(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.getChooseCurrentMaterials2(request);
    }

    @WebLogger
    @PostMapping("/getChooseCompositeMaterials")
    @ApiOperation(value = "选择材料-生产正式材料并选择到用量表",tags = "成控部-物料管理作业-研发用量建档")
    public ResponseInfo getChooseCompositeMaterials(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.getChooseCompositeMaterials(request);
    }

    @WebLogger
    @PostMapping("/getChooseCompositeMaterials2")
    @ApiOperation(value = "选择材料-生产正式材料并选择到用量表",tags = "业务部-物料管理作业-开发用量建档")
    public ResponseInfo getChooseCompositeMaterials2(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.getChooseCompositeMaterials2(request);
    }

    @WebLogger
    @PostMapping("/getInsertMaterial")
    @ApiOperation(value = "贴合材料处理-插入材料",tags = "成控部-物料管理作业-研发用量建档")
    public ResponseInfo getInsertMaterial(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.getInsertMaterial(request);
    }

    @WebLogger
    @PostMapping("/getInsertMaterial2")
    @ApiOperation(value = "贴合材料处理-插入材料",tags = "业务部-物料管理作业-开发用量建档")
    public ResponseInfo getInsertMaterial2(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.getInsertMaterial2(request);
    }

    @WebLogger
    @PostMapping("/restoration")
    @ApiOperation(value = "贴合材料处理-还原",tags = "成控部-物料管理作业-研发用量建档")
    public ResponseInfo restoration(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.restoration(request);
    }

    @WebLogger
    @PostMapping("/restoration2")
    @ApiOperation(value = "贴合材料处理-还原",tags = "成控部-物料管理作业-开发用量建档")
    public ResponseInfo restoration2(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.restoration2(request);
    }

    @WebLogger
    @PostMapping("/getChooseCurrentBomMaterials")
    @ApiOperation(value = "选择材料-选择当前行正式材料到用量表",tags = "成控部-物料管理作业-大货用量建档")
    public ResponseInfo getChooseCurrentBomMaterials(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.getChooseCurrentBomMaterials(request);
    }

    @WebLogger
    @PostMapping("/PartExport")
    @ApiOperation(value = "导出",tags = "成控部-物料管理作业-部位资料建档")
    public void PartExport(@RequestBody PartRequest request, HttpServletResponse response){
        partService.PartExport(request,response);
    }

    @WebLogger
    @PostMapping("/getMtlNoByMaterial")
    @ApiOperation(value = "根据物料编号返回材料名称",tags = "成控部-物料管理作业-研发用量建档")
    public ResponseInfo getMtlNoByMaterial(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.getMtlNoByMaterial(request);
    }

    @WebLogger
    @PostMapping("/getMtlNoByMaterial2")
    @ApiOperation(value = "根据物料编号返回材料名称",tags = "成控部-物料管理作业开发用量建档")
    public ResponseInfo getMtlNoByMaterial2(@RequestBody AdhesiveMaterialChooseRequest request){
        return partService.getMtlNoByMaterial2(request);
    }


    @WebLogger
    @PostMapping("/getMtlNameByMaterial")
    @ApiOperation(value = "根据物料名称返回信息",tags = "成控部-物料管理作业-研发用量建档")
    public ResponseInfo getMtlNameByMaterial(@RequestBody Map<String,String> map){
        return partService.getMtlNameByMaterial(map);
    }

    @WebLogger
    @PostMapping("/delMtlNoByMaterial")
    @ApiOperation(value = "选择材料-根据物料编码删除",tags = "成控部-物料管理作业-研发用量建档")
    public ResponseInfo delMtlNoByMaterial(@RequestParam String mtlNo){
        return partService.delMtlNoByMaterial(mtlNo);
    }

    @WebLogger
    @GetMapping("/getPartName")
    @ApiOperation(value = "查询部位",tags = "成控部-物料管理作业-研发用量建档")
    public ResponseInfo getPartName(@RequestParam String partName){
        return partService.getPartName(partName);
    }
}
